remove pointless NULL checks before free()
authorvh249@arcadians.cl.cam.ac.uk <vh249@arcadians.cl.cam.ac.uk>
Fri, 12 Aug 2005 10:48:42 +0000 (10:48 +0000)
committervh249@arcadians.cl.cam.ac.uk <vh249@arcadians.cl.cam.ac.uk>
Fri, 12 Aug 2005 10:48:42 +0000 (10:48 +0000)
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
tools/libxc/xc_core.c
tools/libxc/xc_linux_build.c
tools/libxc/xc_linux_restore.c
tools/libxc/xc_linux_save.c
tools/libxc/xc_load_elf.c
tools/libxc/xc_vmx_build.c

index 653512ab924d07cb5af4f047be557e9a651116cd..19f20f65ad9216f1c885cb34e9a40f1d7dd941d0 100644 (file)
@@ -110,7 +110,6 @@ xc_domain_dumpcore(int xc_handle,
  error_out:
        if (dump_fd)
                close(dump_fd);
-       if (dump_mem_start)
-               free(dump_mem_start);
+       free(dump_mem_start);
        return -1;
 }
index 48cace56473157b31246134661de7a34c01759f1..45044c0735a330d416692be601fe9d9b6500e48d 100644 (file)
@@ -318,8 +318,7 @@ static int setup_guest(int xc_handle,
     return 0;
 
  error_out:
-    if ( page_array != NULL )
-        free(page_array);
+    free(page_array);
     return -1;
 }
 #else /* x86 */
@@ -616,10 +615,8 @@ static int setup_guest(int xc_handle,
     return 0;
 
  error_out:
-    if ( mmu != NULL )
-        free(mmu);
-    if ( page_array != NULL )
-        free(page_array);
+    free(mmu);
+    free(page_array);
     return -1;
 }
 #endif
@@ -719,8 +716,7 @@ int xc_linux_build(int xc_handle,
         close(initrd_fd);
     if ( initrd_gfd )
         gzclose(initrd_gfd);
-    if ( image != NULL )
-        free(image);
+    free(image);
 
 #ifdef __ia64__
     /* based on new_thread in xen/arch/ia64/domain.c */
@@ -806,8 +802,7 @@ int xc_linux_build(int xc_handle,
         gzclose(initrd_gfd);
     else if ( initrd_fd >= 0 )
         close(initrd_fd);
-    if ( image != NULL )
-        free(image);
+    free(image);
 
     return -1;
 }
index c2bce4391075fbef78e897bcb8a80ae946124aa2..c4375c372e29a9b68deaeea0fe15aec1c752944e 100644 (file)
@@ -607,12 +607,9 @@ int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns,
  out:
     if ( (rc != 0) && (dom != 0) )
         xc_domain_destroy(xc_handle, dom);
-    if ( mmu != NULL )
-        free(mmu);
-    if ( pfn_to_mfn_table != NULL )
-        free(pfn_to_mfn_table);
-    if ( pfn_type != NULL )
-        free(pfn_type);
+    free(mmu);
+    free(pfn_to_mfn_table);
+    free(pfn_type);
 
     DPRINTF("Restore exit with rc=%d\n", rc);
     return rc;
index c2a6af5f1358247fd0a39a826e42e790e354adf2..a66ada565d968211bdf047dc8ed879a25260b7d1 100644 (file)
@@ -1051,20 +1051,11 @@ int xc_linux_save(int xc_handle, int io_fd, u32 dom)
     if(live_mfn_to_pfn_table) 
         munmap(live_mfn_to_pfn_table, PAGE_SIZE*1024);
 
-    if (pfn_type != NULL) 
-        free(pfn_type);
-
-    if (pfn_batch != NULL)
-        free(pfn_batch);
-
-    if (to_send != NULL)
-        free(to_send);
-
-    if (to_fix != NULL)
-        free(to_fix);
-
-    if (to_skip != NULL)
-       free(to_skip);
+    free(pfn_type);
+    free(pfn_batch);
+    free(to_send);
+    free(to_fix);
+    free(to_skip);
 
     DPRINTF("Save exit rc=%d\n",rc);
     return !!rc;
index 926db3a9648f42de1d2b154046a875f5fee30263..90417fb2ca2e436759261c437f9fa63c43e20a2f 100644 (file)
@@ -309,8 +309,7 @@ loadelfsymtab(
     dsi->v_end = round_pgup(maxva);
 
  out:
-    if ( p != NULL )
-        free(p);
+    free(p);
 
     return 0;
 }
index 98367469194bb48c7b88efe4514d7e7ae0b7e425..ecd1d39b52d482e5e754e8ab561d40a75e770d83 100644 (file)
@@ -616,10 +616,8 @@ static int setup_guest(int xc_handle,
     return 0;
 
  error_out:
-    if ( mmu != NULL )
-        free(mmu);
-    if ( page_array != NULL )
-        free(page_array);
+    free(mmu);
+    free(page_array);
     return -1;
 }
 
@@ -745,8 +743,7 @@ int xc_vmx_build(int xc_handle,
         close(initrd_fd);
     if ( initrd_gfd )
         gzclose(initrd_gfd);
-    if ( image != NULL )
-        free(image);
+    free(image);
 
     ctxt->flags = VGCF_VMX_GUEST;
     /* FPU is set up to default initial state. */
@@ -801,8 +798,7 @@ int xc_vmx_build(int xc_handle,
         gzclose(initrd_gfd);
     else if ( initrd_fd >= 0 )
         close(initrd_fd);
-    if ( image != NULL )
-        free(image);
+    free(image);
 
     return -1;
 }